<?php namespace Home\Model;

use Framework\Model\Model;
use Framework\Model\Db;
class Ans extends Model{

	//调入问题表
	public $table = 'answer';

	//将表单数据存入回答表
	public function ans()
	{	
		// echo 333;
			$sql = "INSERT INTO answer (content,create_ad,aid,user_id) VALUES(?,?,?,?)";
			// p($sql);
			$data = [
				'content'=>$_POST['content'],
				'create_ad'=>time(),
				'aid'=>$_POST['aid'],
				'user_id'=>$_SESSION['id']
			];
			// p($data);
			if($this->execute($sql,$data))
			{
				return $this->getInsertId();			
			}else{
				$this->error ='添加失败';
				return false;
			}
	}
}